{include file="common/head"/}
<style>
.addset{
    display: flex;
    margin-left: 30px;
}
.FancyForm {
    margin-top: 10px;
    margin-left: 30px;
}
.FancyForm li {
    width: 450px;height: 35px;
}
.FancyForm li input {
    width: 75px;float: left;height: 20px;font-size:2px
}
.FancyFormSpan {
    float: left;line-height: 25px;
}
.FancyFormSpan1 {
    margin: 0 2px 0 10px;float: left;font-size:2px;line-height: 25px;
}
.buttonStyle {
    margin-left: 10px;font-size:14px;float: left;
}
</style>

<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
    <form class="layui-form layui-form-pane" lay-filter="form">
        <div class="addset">
            <button type="button" class="FancyFormButton layui-btn layui-btn-xs" >添加一列</button>
        </div>
        <ul class="Form FancyForm" >
            {if $count > 0}
                {volist name="info" key="index" id="vo"}
                    <li >
                        <input name="config[{$index}][start_money]" placeholder="开始金额" type="text" class="stext" value="{$vo.start_money}">
                        <span class="FancyFormSpan">~~</span>
                        <input name="config[{$index}][end_money]"  placeholder="结束金额" type="text" class="stext" value="{$vo.end_money}">
                        <span  class="FancyFormSpan1" style="">提成百分比%</span>
                        <input  name="config[{$index}][num]"  placeholder="数字" type="text" class="stext" value="{$vo.num}">
                        <button type="button" class="buttonStyle FancyFormButtonCancel layui-btn layui-btn-danger layui-btn-xs" >移除</button>
                    </li>
                {/volist}
            {/if}
        </ul>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}
<script>
    var liLenth = {$count};

    layui.use(['form', 'layer','upload'], function () {
        var form = layui.form, layer = layui.layer,$= layui.jquery;
        form.render();
        form.on('submit(submit)', function (data) {
            loading =layer.load(1, {shade: [0.1,'#fff']});
            $.post("", data.field, function (res) {
                layer.close(loading);
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 2800, icon: 1}, function () {
                        window.parent.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {time: 2800, icon: 2});
                }
            });
        });
    });

    //取消处理
    $(document).on('click','.FancyFormButtonCancel',function (){
        $(this).parent().remove();
    })

    //添加处理
    $(document).on('click','.FancyFormButton',function (){
        liLenth ++;
        var list = $(this).parent().children('input');
        for(i=0;i<list.length;i++){
            console.log(list[i].value);
        }
        var html = "<li >\n" +
            "                <input name=\"config["+liLenth+"][start_money]\" placeholder=\"开始金额\" type=\"number\" class=\"stext\">\n" +
            "                <span class=\"FancyFormSpan\">~~</span>\n" +
            "                <input name=\"config["+liLenth+"][end_money]\" placeholder=\"结束金额\" type=\"number\" class=\"stext\">\n" +
            "                <span  class=\"FancyFormSpan1\" style=\"\">提成百分比%</span>\n" +
            "                <input name=\"config["+liLenth+"][num]\" placeholder=\"数字\" type=\"number\" class=\"stext\">\n" +
            "                <button type=\"button\" class=\"buttonStyle FancyFormButtonCancel layui-btn layui-btn-danger layui-btn-xs\" >移除</button>\n" +
            "            </li>"
        $(".FancyForm").append(html)
    });


</script>